#pragma once

#include <QMainWindow>
#include <QLabel>
#include <memory>
#include "qMeasureDialog.h"

namespace Ui {
class MainWindow;
}

#define PACKAGE_ORGANIZATION "航天远景"
#define PACKAGE_NAME "MapMatrix3D"
#define PACKAGE_VERSION "1.0.2"

const int maxRecentlyOpenedFile = 10;

class xTreeView;
class xSceneView;
class IEventCall;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);

    ~MainWindow();

    /**
     * @brief loadFile 加载场景
     * @param file 场景路径名
     */
    bool loadFile(const QString &file);

    /**
     * @brief unloadAll 卸载场景
     */
    void unloadAll();

public slots:
    void recentFileActivated(QAction *action);

    void setupRecentFilesMenu();

private slots:
    void on_actionOpen_triggered();

    void on_actionUnload_triggered();

    void on_actionSave_As_triggered();

    void on_actionQuit_triggered();

    void on_actionReset_View_triggered();

    void on_actionTexture_triggered();

    void on_actionLight_triggered();

    void on_actionHighLight_triggered();

    void on_actionShadow_triggered();

    void on_actionFull_Screen_triggered();

    void on_actionFrontView_triggered();

    void on_actionRearView_triggered();

    void on_actionLeftView_triggered();

    void on_actionRightView_triggered();

    void on_actionLookUpView_triggered();

    void on_actionLookDownView_triggered();

    void on_actionMeasurePt_triggered();

    void on_actionMeasureLine_triggered();

    void on_actionMeasureMulLine_triggered();

    void on_actionMeasureArea_triggered();

private:
    /**
     * @brief saveSettings 保存ui设置
     * @value
     */
    void saveSettings();

    /**
     * @brief loadSettings 加载ui设置
     * @value
     */
    void loadSettings();

    /**
     * @brief addRecentlyOpenedFile 打开最近打开的文件
     * @value
     */
    void addRecentlyOpenedFile(const QString &fn, QStringList &lst);

    /**
     * @brief updateUi 更新ui
     * @value
     */
    void updateUi();

    /**
     * @brief updateApplicationIdentity 更新界面设置
     * @value
     */
    void updateApplicationIdentity();

    /**
     * @brief initUi 初始化界面
     * @value
     */
    void initUi();

private:
    Ui::MainWindow *ui;

    /**
     * @brief m_pTreeView 侧边栏
     */
    xTreeView *m_pTreeView;

    /**
     * @brief m_pSceneView 三维场景
     */
    xSceneView *m_pSceneView;

    /**
     * @brief m_currFile 当前文件
     * @brief m_lastDirectory 最后一个文件
     */
    QString m_currFile;
    QString m_lastDirectory;

    /**
     * @brief m_recentFilesMenu 最近文件菜单
     * @brief m_recentFiles 最近文件
     */
    QMenu *m_recentFilesMenu;
    QStringList m_recentFiles;

    /**
     * @brief m_aspectRatioLabel 视角
     */
    QLabel *m_aspectRatioLabel;

    /**
     * @brief m_qmDialog 测量对话框
     */
    qMeasureDialog* m_qmDialog;

    /**
     * @brief m_pEventCall 事件回调类
     */
    typedef std::shared_ptr<IEventCall> ptrEventCallback;
    ptrEventCallback m_pEventCall;
};


